package iammry.com.activity;

import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.alibaba.sdk.android.feedback.impl.FeedbackAPI;
import com.lidroid.xutils.view.annotation.ViewInject;

import iammry.com.R;
import iammry.com.base.BaseActivity;

/**
 * Created by kim
 * on 2016/11/19 0019.
 */

public class FeedbackActivity extends BaseActivity {
    @ViewInject(R.id.et_content)
    EditText et_content;

    @ViewInject(R.id.bt_commit)
    Button bt_commit;

    @ViewInject(R.id.tv_tittle)
    TextView tv_tittle;

    @Override
    protected void initView() {

        setLayout(this, R.layout.feedback_layout);
        tv_tittle.setText("意见反馈");

    }

    @Override
    protected void initData() {
        /**
         * 判断状态
         */
        bt_commit.setBackgroundResource(R.mipmap.btn_a_d);
        et_content.addTextChangedListener(textWatcher);

    }

    @Override
    protected void initEvent() {

        et_content.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                return false;
            }
        });
        bt_commit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {



                FeedbackAPI.openFeedbackActivity();
            }
        });
    }

    private TextWatcher textWatcher = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
//
            if (et_content.getText().toString().isEmpty())
            {
                bt_commit.setBackgroundResource(R.mipmap.btn_a_d);
            }
            else
            {
                bt_commit.setBackgroundResource(R.mipmap.btn_a_n);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
//


        }

        @Override
        public void afterTextChanged(Editable s) {
//


        }
    };
}
